﻿using Caliburn.Micro;
using LearnEnglishWords.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Media.SpeechSynthesis;

namespace LearnEnglishWords.UI.ViewModels
{
    public class EnglishCardViewModel : BaseViewModel
    {
        private String _englishWord;
        public String EnglishWord
        {
            get
            {
                return _englishWord;
            }
            set
            {
                _englishWord = value;
                NotifyOfPropertyChange();
            }
        }

        private String _examples;
        public String Examples
        {
            get
            {
                return _examples;
            }
            set
            {
                _examples = value;
                NotifyOfPropertyChange();
            }
        }

        protected override void OnActivate()
        {
            base.OnActivate();

            _circlesModel.WordChanged += _circlesModel_WordChanged;
            Init();
        }

        protected override void OnDeactivate(bool close)
        {
            _circlesModel.WordChanged -= _circlesModel_WordChanged;

            base.OnDeactivate(close);
        }

        void _circlesModel_WordChanged()
        {
            Init();
        }

        public void Init()
        {
            EnglishWord = _circlesModel.CurrentWord == null ? "" : _circlesModel.CurrentWord.EnglishWord;
            Examples = _circlesModel.CurrentWord == null ? "" : _circlesModel.CurrentWord.Examples;
        }
    }
}
